package roborally.commandCombiners;
import java.util.List;

import be.kuleuven.cs.som.annotate.Basic;

import roborally.*;
import roborally.Conditions.*;
import roborally.Commands.*;

/**
 * A class of Sequence-commands for playing the roborally game, involving a list of commands.
 * 
 * @version  2.90
 * @author   Michiel Ruelens & Dieter Naten
 */
public class Sequence extends CommandCombiner {
	
	private final List<Statement> commandList;
	
	/**
	 * Initialise the new sequence-command with the given parameters.
	 * @param 	commandList
	 * 			The list of commands that this sequence contains.
	 */
	public Sequence(List<Statement> commandList){
		assert(commandList.size()!=0);
		for(Statement c : commandList){
			assert(c instanceof Command || c instanceof CommandCombiner);
		}
		this.commandList = commandList;
		this.setStringForm("seq");
		for(Statement c: commandList){
			this.setStringForm(this.getStringForm()+" ("+c.getStringForm()+")");
		}
	}
	
	/**
	 * Execute this sequence statement for the given robot. This will execute all the comands in the given list.
	 * @param	robot
	 * 			The robot that wants to execute this command.
	 */
	public void execute(Robot robot){
		for(Statement c: commandList){
			c.execute(robot);
		}
	}

	/**
	 * Get this sequence's commandList.
	 */
	@Basic
	public List<Statement> getCommandList() {
		return commandList;
	}
	

}
